package handlers

import (
	"context"
	"github.com/gin-gonic/gin"
	log "github.com/sirupsen/logrus"
	"github.com/twwch/gin-sdk/handler"
	"github.com/twwch/gin-sdk/server"
	"net/http"
	podSvc "twwch/k8s-admin/application/pod"
	"twwch/k8s-admin/models/pod"
)

type PodHandler struct {
	handler.Base
	podSvc *podSvc.PodService
}

func (h *PodHandler) Init(ginRouter *gin.RouterGroup) {
	h.Logger = log.WithField("handler", "pods")
	h.podSvc = podSvc.GetService()
	// registry http handler
	if ginRouter != nil {
		appGroup := ginRouter.Group("/pod")
		server.Route(appGroup, http.MethodGet, "/list", h.List)
	}
}

func (h *PodHandler) List(ctx context.Context, req *pod.ListReq) (*pod.ListResp, error) {
	return h.podSvc.List(ctx, req)
}
